package service.JCXX;

import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import Dao.JCXX.Cl0001Mapper;
import Model.JCXX.Cl0001;

@Service
public class cl0001Service {

	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private Cl0001Mapper cl;

	public void GetList() {
		// jdbcTemplate.update("INSERT INTO SYS_USER(userid) VALUES('1')");
		System.out.println("2");
		String sqlString = "";
		int count = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM SYS_USER");
		System.out.println("count:" + count);
		String count1 = (String) jdbcTemplate.queryForObject(
				"SELECT userid FROM SYS_USER where userid='1'", String.class);
		System.out.println("count1:" + count1);
		List rows = jdbcTemplate
				.queryForList("SELECT * FROM SYS_USER where userid='3'");
		Iterator it = rows.iterator();
		while (it.hasNext()) {
			Map userMap = (Map) it.next();
			System.out.println(userMap.get("userid") + "\t");
		}
		System.out.println("3");
	}

	public List<Cl0001> selectAll() {
		return cl.selectAll();
	};

	public void addT() {
		String sql = "insert into cl0001(dwbm,zbbm,nf,yf) values('2019','2019','2019','2019')";
		jdbcTemplate.update(sql);
	}

	@Transactional
	public void add() {
		Cl0001 model = new Cl0001();
		BigDecimal bd = new BigDecimal("2019");
		model.setNf(bd);
		model.setYf(bd);
		model.setZbbm("1");
		model.setDwbm("1");
		model.setCj(bd);
		model.setHc(bd);
		model.setZbmc("");
		model.setZbdm("");
		model.setJldw("");
		model.setQyjy("");
		model.setXsyc("");
		model.setSfkbj("");
		model.setSfmj("");
		model.setCol51(bd);
		model.setCol52(bd);
		model.setCol53(bd);
		model.setCol54(bd);
		cl.insert(model);
		// model.setDwbm("111");
		cl.insert(model);
		try {
		} catch (Exception e) {

			throw new RuntimeException();

		}
		// List<Cl0001> lll=cl.selectAll();
		// System.out.println(lll);
	}
}
